/*
 * Л.р. 6, вариант 3
 */
package syntaxAnalyzer;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class SyntaxAnalyzer {

    public static boolean isValid(String input) {

        String regex = "^(([a-z])+(, [a-z])*)(; (([a-z])+(, [a-z])*))*$";
 
        Pattern pattern = Pattern.compile(regex);
        Matcher matcher = pattern.matcher(input);
        return matcher.matches();
    }
    
    public static void main(String[] args) {
        System.out.println(isValid("a, b, c; d, e; f"));
    }
}
